<?php 
include("common.php");
$id=$_GET['id'];
$spsql = "select * from book where id='$id'";
$spres = mysql_query($spsql);
$book=mysql_fetch_array($spres);
if(isset($_POST['submit'])){
    $book_id = $_POST['book_id'];
	$book_name = $_POST['book_name'];
	$price = $_POST['price'];
	$author = $_POST['author'];
	$Press = $_POST['Press'];
	$addate = $_POST['addate'];
$sql = "update book set book_id='$book_id', book_name='$book_name', price='$price', author='$author', Press='$Press', addate='$addate' where id='$id'";
	$result = mysql_query($sql);
	$rows=mysql_affected_rows();
	if($rows<1){
		echo "<script>alert('修改失败！');window.location.href='book.php';</script>";
	}else{
		echo "<script>alert('修改成功！');window.location.href='book.php';</script>";
	}

}

?>

 <div class="fr righter">
		  <div class="title">
		   <h1 align="center">修改图书信息</h1>
	      </div>
		  
		  <table class="bd" width="600" align="center">
		  <form action="#" method="post">
          		      <tr>
				  <td height="30" align="center">图书编号：</td>
			    <td align="center"><input type="text" name="book_id"  value="<?php echo $book['book_id']?>"/></td>
			  </tr>
		      <tr>
				  <td height="30" align="center">图书名称：</td>
			    <td align="center"><input type="text" name="book_name"  value="<?php echo $book['book_name']?>"/></td>
			  </tr>
			  <tr>
				  <td height="30" align="center">图书价格：</td>
			    <td align="center"><input type="text" name="price"  value="<?php echo $book['price']?>"/></td>
			  </tr>
			  <tr>
				  <td height="30" align="center">作者：</td>
			    <td align="center"><input type="text" name="author"  value="<?php echo $book['author']?>"/></td>
			  </tr>
			  <tr>
				  <td height="30" align="center">出版社：</td>
			    <td align="center"><input type="text" name="Press"  value="<?php echo $book['Press']?>"/></td>
			  </tr>
			  <tr>
				  <td height="30" align="center">出版时间：</td>
			    <td align="center"><input type="text" name="addate"  value="<?php echo $book['addate']?>"/></td>
			  </tr> 	
			  <tr>
				  <td height="30" colspan=2 align="center"><input type="submit" name="submit" value="修改"/></td>
			  </tr>
		  </form>
	   </table>

	  </div>
  </div>
  
 </body>
</html>
 

